from courses.models import Course

#get_files will be called when you ask for course.files
def get_files(self):
    from models import CourseFileTree
    return CourseFileTree(self.instructor.user.username, self.slug)

Course.files = property(get_files)

title = 'Files'

tab = False

def enable_hook(course):
    from models import DEFAULT_DIRS, CourseFileTree
    print 'Running enable_hook for "files"...'
    
    course.files.save()
    
    course.files.load_defaults()
        
def disable_hook(course):
    print 'Running disable_hook for "files"...'
    course.files.delete()
    
def save_hook(course):
    print 'Running save_hook for "files"...'
    from models import CourseFileTree
    import os
    try:
        course.files.save()
    except CourseFileTree.DoesNotExist, os.error:
        enable_hook(course)



